#pragma once
#include"HashTable.h"

namespace dan
{
	template<class K>
	class unordered_set
	{
		struct SetKeyOfT
		{
			const K& operator()(const K& k)
			{
				return k;
			}
		};
	public:
		typedef typename hash_bucket::HashTable<const K, K, SetKeyOfT>::Iterator iterator;
		typedef typename hash_bucket::HashTable<const K, K, SetKeyOfT>::ConstIterator const_iterator;
	public:
		iterator begin()
		{
			return _ht.Begin();
		}

		iterator end()
		{
			return _ht.End();
		}

		const_iterator begin()const
		{
			return _ht.Begin();
		}

		const_iterator end()const
		{
			return _ht.End();
		}

		pair<iterator,bool> insert(const K& k)
		{
			return _ht.Insert(k);
		}

		iterator find(const K& k)
		{
			return _ht.Find(k);
		}

		bool erase(const K& k)
		{
			return Erase(k);
		}

	private:
		hash_bucket::HashTable<const K, K,SetKeyOfT> _ht;
	};

	void Print(const unordered_set<int>& s)
	{
		unordered_set<int>::const_iterator it = s.begin();
		while (it != s.end())
		{
			 //*it = 1;
			cout << *it << " ";
			++it;
		}
		cout << endl;
	}

	void test_set()
	{
		unordered_set<int> s;
		s.insert(4);
		s.insert(14);
		s.insert(2);
		s.insert(12);
		s.insert(2);
		s.insert(222);
		s.insert(21);
		/*for (const auto& e : s)
		{
			cout << e << endl;
		}*/
		/*unordered_set<int>::iterator it = s.begin();
		while (it != s.end())
		{
			cout << *it << " ";
			++it;
		}*/
		//cout << endl;
		Print(s);
	}
}
